feat: multi-tenant — let a learner choose which Open edX platform to sign in to - #496
feat: multi-tenant — let a learner choose which Open edX platform to sign in to#496IvanStepanok wants to merge 5 commits into
Conversation
A build normally talks to exactly one site, named in config.yaml. With LMS_DIRECTORY enabled it instead shows the platforms listed in a JSON document, re-themes to whichever the learner picks — logo, accent colour, sign-in artwork — and signs in against that one. Logging out returns to the list, so a device can move between platforms without a new build. Off by default: with ENABLED false none of this runs. The document is the whole contract. It comes from a URL or from the app's assets, and nothing downstream can tell which — so a build can ship its list and its images and never ask the network for either. Because the whole list arrives at once, every platform's sign-in background is known before anything is tapped, which is what lets that artwork be warmed while the learner is still choosing rather than assembling itself afterwards. Image references carry either an http(s) address or the name of a file in assets, which Coil reads as file:///android_asset/… natively. One field, one rule: the alternative was a parallel set of asset fields and a precedence rule to go with them, which puts the rule in documentation instead of in the value. Documentation/LMSDirectory.md has the format, both delivery modes and a worked example.
|
Thanks for the pull request, @IvanStepanok! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
The app crashed on launch with the directory configured: Koin had no definition for SiteSelectionViewModel, so the very first screen threw. Unit tests and the build were both green — it took running the app to see it. The rest is design parity, from putting the two screens side by side: - the title sat under the status bar, so the screen needed statusBarsPadding; - secondary text used appColors.textSecondary, which on Android is a light grey (#B3B3B3) while the token of that name on iOS is the slate #3D4964. The colour iOS actually draws is textPrimaryVariant here, so the subtitle, the host, the provider line and the chevron all use that; - the chevron was the accent colour, where iOS draws it in the same secondary ink as the text; - rows padded 12/10/10/4 against iOS's even 16, and the platform name used a title style where iOS uses bodyLarge.
|
To test this MR you can create a JSON file by using my service: https://providers.openedx-lms.stepanok.com |
The wire format here already allowed it — api and oauth_client_id are nullable, and Config falls back to the app's own client id. Nothing to change, but the mobile working group settled that this is the model rather than an accident, so it is worth a test that fails if someone tightens the DTO later. The matching iOS change makes the same document decode there.
The file the apps read now says `format`, `include`, `name`, `description`, `url` and `logo`, matching the schema being settled in the mobile working group rather than the column names of the registry that happened to produce the first one. A file written by hand and a file exported from a registry are now the same shape, which was the point. `id` becomes optional with it: a platform that names none is identified by its address, which is unique within a directory anyway. Also finishes the design parity pass. A platform with no logo drew one initial on a tinted square here and two white initials on a filled one on iOS; both now draw the filled badge, since that fallback only shows up for platforms that never uploaded a logo — exactly the ones nobody looked at while comparing.
|
Excited to see this move forward! Could you add to your PR description to explain how AI was used and how you validated AI-generated code? https://github.com/openedx/.github/blob/master/AI_POLICY.md#pull-requests |
The id came from the registry that produced the first document, where it is a primary key. It means nothing to a client, so the schema is better without it. What replaces it is the position in the file, not the URL. Two entries may legitimately name the same address — the same LMS listed twice under different branding — and identifying by URL merges them, so opening one row would give another row's settings. Compose survived that by accident, because the list is keyed by index; iOS did not, which is how it was found. A test holds a two-entry document that shares one address, so neither platform can regress into merging them.
What this adds
A build of this app normally talks to exactly one Open edX site, named in
config.yaml. WithLMS_DIRECTORYenabled it instead shows a list of platforms,lets the learner pick one, re-themes to it — logo, accent colour, sign-in artwork
— and signs in against that one. Logging out returns to the list, so a device can
move between platforms without a new build.
Off by default. With
ENABLED: falsenone of this runs and the app behavesexactly as it does today. Every shipped config in this PR has it disabled with no
source set.
Where the list comes from
One JSON document, given either way — never both:
A bundled file wins over an address: a build that ships its own copy has
deliberately opted out of the network, and quietly preferring a remote list would
undo that. Image fields inside the document are either web addresses or names of
files shipped with the app, so a build can be fully offline — list and artwork
both — and still be branded.
Because the whole list arrives at once, every platform's sign-in background is
known before anything is tapped. That is what makes it possible to warm the
artwork while the learner is still choosing, instead of watching the branded
screen assemble itself afterwards.
Format, both delivery modes and a worked example:
Documentation/LMSDirectory.md.Scope
Multi-tenancy only: read a list, choose, sign in, log out, choose again. No
search, no QR sign-in, no reporting a platform, and nothing that talks to a
catalog service — the app knows about a document and nothing else. Those belong
to a universal-app phase and will come as their own PRs.
Testing
Unit tests across
core,auth,appandprofile: 281 tests, 0 failures,with
detektAllclean over the whole project. They cover which source a configresolves to, reading a document from assets and from a URL, image references
resolving to an address or to
file:///android_asset/…, the picker's states, andwhat choosing a platform writes — the host, OAuth client and branding everything
downstream reads.
One of them pins the smallest document a person could reasonably write by hand,
because the same file has to work on iOS too.
Notes for reviewers
BaseUrlOverrideInterceptoris what makes the chosen platform the one the apptalks to, so a single-tenant build is unaffected: with nothing selected it does
not rewrite anything.
learner is not silently handed the previous one's host and branding.